home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0126_32x32 Bitmap Tiles.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  5KB  |  144 lines

  1.  
  2. {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V-,X+,Y+}
  3. {$M 16384,0,655360}
  4. Program Tiles;         { by Paul H. Kahler 1994 }
  5. USES CRT;            {email:  phkahler@oakland.edu}
  6.  
  7. { This program is mostly undocumented. If you want to know whats going on,
  8.   see the other program, it has more comments and much of the same code, so
  9.   it should be more helpful. This version doesn't account for the non-square
  10.   pixels in mode 13h (see the other program to fix that) and it's slower
  11.   because a different fixed-point format is used (see the hloop of both
  12.   programs). I like it because it's shorter and simpler. }
  13.  
  14. { A 32x32 bitmap is defined in the data below. Feel free to change it to
  15.   whatever you like, I just punched in the first thing that came to mind. }
  16.  
  17. Const Tile: array [0..1023] of byte =
  18.    ( 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  19.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  20.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  21.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  22.      2,0,0,0,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  23.      2,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  24.      2,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  25.      2,0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,0,
  40.      2,0,0,0,0,0,3,3,3,3,0,0,3,3,3,0,0,0,3,3,3,0,0,3,0,0,0,0,0,0,0,0,
  41.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  42.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  43.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  44.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  45.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  46.      2,0,0,0,0,0,3,3,3,3,0,0,3,3,3,0,0,0,3,3,3,0,0,3,3,3,3,3,0,0,0,0,
  47.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  48.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  49.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 );
  50.  
  51. Var   SinTable,CosTable: Array[0..255] of longint;
  52.  
  53. Procedure MakeTables;
  54. Var direction:integer;
  55.     angle:real;
  56. begin
  57.      For Direction:=0 to 255 do begin
  58.          angle:=Direction;
  59.          angle:=angle*3.14159265/128;
  60.          SinTable[Direction]:=round(Sin(angle)*256);
  61.          CosTable[Direction]:=round(Cos(angle)*256);
  62.      end;
  63. end;
  64.  
  65. Procedure GraphMode;  {set 320x200x256 mode}
  66. begin
  67.      Asm
  68.         Mov     AH,00
  69.         Mov     AL,13h
  70.         Int     10h
  71.      end;
  72. end;
  73.  
  74. Procedure DrawScreen(x,y:word; rot,scale:byte);
  75. var Temp:Longint;
  76.     ddx,ddy,d2x,d2y:word;
  77.     i,j:word;
  78.     label hloop,vloop;
  79.  
  80. begin
  81.      Temp:=(CosTable[rot]);Temp:=(Temp*Scale) div 32;
  82.      ddx:=Temp;
  83.      Temp:=(SinTable[rot]);Temp:=(Temp*Scale) div 256;
  84.      ddy:=Temp;
  85.      Temp:=(CosTable[(rot+64) and 255]);Temp:=(Temp*SCALE) div 32;
  86.      d2x:=Temp;
  87.      Temp:=(SinTable[(rot+64) and 255]);Temp:=(Temp*SCALE) div 256;
  88.      d2y:=Temp;
  89.      i:=x-ddx*160-d2x*100; j:=y-ddy*160-d2y*100;
  90.  
  91.          ASM
  92.                  mov  ax,0
  93.                  mov  di,ax
  94.                  mov  ax,$a000
  95.                  mov  es,ax
  96.                  mov  cx,200
  97.          vloop:
  98.                  push cx
  99.                  mov  ax,[i]
  100.                  mov  dx,[j]
  101.                  mov  cx,320
  102.          hloop:
  103.                  add  ax,[ddx]
  104.                  add  dx,[ddy]
  105.                  mov  bl,ah
  106.                  mov  bh,dh
  107.                  shr  bx,3
  108.                  and  bx,$03FF
  109.                  add  bx,OFFSET tile
  110.                  mov  si,bx
  111.                  movsb
  112.                  loop hloop
  113.  
  114.                  mov  ax,d2x
  115.                  add  i,ax
  116.                  mov  ax,d2y
  117.                  add  j,ax
  118.                  pop  cx
  119.                  loop vloop
  120.          end;
  121. end;
  122.  
  123. Var dist,dd,rot,dr:byte;
  124.     x,y:word;
  125. Begin
  126.      MakeTables;
  127.      GraphMode;
  128.      x:=32768; y:=1024;
  129.      rot:=0; dr:=1;
  130.      dist:=127; dd:=255;
  131.      repeat
  132.         DrawScreen(x,y,rot,dist);
  133.         rot:=rot+dr;
  134.         y:=y+128;
  135.         dist:=dist+dd;
  136.         if (dist=250) or (dist=3) then dd:=-dd;
  137.         if random(150)=3 then begin
  138.            dr:=0; while dr=0 do dr:=random(5)-3; end;
  139.      until keypressed;
  140.      ASM {back to 80x25}
  141.       MOV AX,3
  142.       INT 10h
  143.      END;
  144. end.